import mongoose from './mongo.js'
const Schema = mongoose.Schema
const store = new Schema({
    proposer: String,
    bumenpro: String,
    dancode: String,
    title: String,
    name: String,
    code: String,
    position: String,
    serial: Number,
    context: String,
    date: {
        type: Date,
        default: Date.now
    }
})

const supplier = new Schema({
    proposer: String,//申请人
    bumenpro: String,//申请部门
    dancode: String,//单号
    name: String,//客户名称
    setname: String,//所属人
    clienttype: String,//客户类型
    source: String,//来源
    unit: String,//单位
    phone: String,//电话
    phones: String,//手机
    province: String,//省
    city: String,//市
    email: String,//邮箱
    address: String,//地址
    traffic: String,//交通路线
    state: {
        type: Boolean,
        default: false
    },//状态
    mark: {
        type: Boolean,
        default: false
    },//是否标星
    suppiler: {
        type: Boolean,
        default: false
    },//是否为供应商
    contacts: String,//联系人
    explain: String,//说明
    pactnum: Number,//合同数量
    rental: String,//销售总额
    due: String,//待收金额
})

const goods = new Schema({
    serial: Number,//编号
    name: String,//名称
    type: String,//分类
    price: Number,//单价
    unit: String,//单位
    specification: String,//规格
    model: String,//model
    repertory: Number,//repertory
})

const goodsType = new Schema({
    name: String,//分类名称
})

const goodsTypeSize = new Schema({
    name: String,//规格名称
    type_id: {
        type: Schema.Types.ObjectId,
        ref: 'goodsType'//关联分类
    }
})

const todostort = new Schema({
    dancode: String,//单号
    proposer: String,//申请人
    bumenpro: String,//申请部门
    type: String,//分类
    forTime: {
        type: Date,
        default: Date.now
    }, //申请日期
    setTime: {
        type: Date,
        default: Date.now
    }, //操作时间
    context: String,//说明
    state: {
        type: Boolean,
        default: false
    },//状态
})

const in_out_details = new Schema({
    
})


const indexModel = mongoose.model('admins', store, 'admins')
const supplierModel = mongoose.model('suppliers', supplier, 'suppliers')
const goodsModel = mongoose.model('goods', goods, 'goods')
const goodsTypeModel = mongoose.model('goodsType', goodsType, 'goodsType')
const goodsTypeSizeModel = mongoose.model('goodsTypeSize', goodsTypeSize, 'goodsTypeSize')
const todostortModel = mongoose.model('todostort', todostort, 'todostort')
export {
    indexModel,
    supplierModel,
    goodsModel,
    goodsTypeModel,
    goodsTypeSizeModel,
    todostortModel
}